package com.heima.wemedia.controller.v1;

import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.*;
import com.heima.wemedia.service.WmManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/comment/manage")
public class WmManageController {
    @Autowired
    private WmManageService wmManageService;

    //查询评论列表
    @PostMapping("/find_news_comments")
    public PageResponseResult findNewsComments(@RequestBody WmFindNewsCommentsDto dto) {
        return wmManageService.findNewsComments(dto);
    }

    //打开关闭评论
    @PostMapping("/update_comment_status")
    public ResponseResult updateCommentStatus(@RequestBody WmUpdateCommentStatusDto dto) {
        return wmManageService.updateCommentStatus(dto);
    }

    //查看评论详情
    @PostMapping("/list")
    public ResponseResult manageList(@RequestBody WmManageDto dto) {
        return wmManageService.commentRepayList(dto);
    }

    //作者回复评论
    @PostMapping("/comment_repay")
    public ResponseResult commentRepay(@RequestBody WmCommentRepayDto dto) {
        return wmManageService.commentRepay(dto);
    }

    //作者点赞评论
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return wmManageService.like(dto);
    }

    //作者删除评论
    @DeleteMapping("del_comment/{commentId}")
    public ResponseResult deleteComment(@PathVariable("commentId") String commentId){
        return wmManageService.delCommentById(commentId);
    }

    //作者删除评论回复
    @DeleteMapping("del_comment_repay/{commentRepayId}")
    public ResponseResult deleteCommentRepay(@PathVariable("commentRepayId") String commentRepayId){
        return wmManageService.delCommentRepayById(commentRepayId);
    }
}
